// import { LOGIN_TOKEN } from '@/global/constants'
// import { localCache } from '@/utils/cache'

import RequestModel from "./request/index"

// 1.区分开发环境和生产环境
// export const BASE_URL = 'http://coderwhy.dev:8000'
// export const BASE_URL = 'http://codercba.prod:8000'

/* 查看当前环境 */
// console.log(process.env.NODE_ENV)
// const BASE_URL = process.env.NODE_ENV === 'development' ? 'http://codercba.com:9002' : 'http://localhost:5174/'
const BASE_URL = 'http://localhost/api/'
const TIME_OUT = 1000000

const request = new RequestModel({
  baseURL: BASE_URL,
  timeout: TIME_OUT,
  interceptors: {
    requestSuccessFn: (config) => {
      // const token = localCache.getCache(LOGIN_TOKEN)
      // if (config.headers && token) {
      //   config.headers.Authorization = 'Bearer ' + token
      // }
      return config
    }
  }
})

export default request
